{extend name='base' /}
{block name='title'}个人中心{/block}
{block name='main'}
<link rel="stylesheet" href="__CSS__/booklist.css">
<link rel="stylesheet" href="__CSS__/booktable.css">
<style>
    .main {
        background: url("__IMG__/list_bg.jpg") left top repeat-y;
    }
</style>
<div class="row m-0 mt-3 main">
    {include file='user/user_left'}
    <div class="right flex-1 table-responsive">
        <table class="tb w-100">
            <thead>
                <tr>
                    <th>封面</th>
                    <th>名称</th>
                    <th>借书日期</th>
                    <th>归还日期</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {foreach $book as $k => $v}
                <tr>
                    <td>
                        <img src="{$v['thumb']}" class="book-img">
                    </td>
                    <td>{$v['bname']}</td>
                    <td>{$v['date_entered']}</td>
                    <td>{$v['back']}</td>
                    <td><a href="javascript:void(0)" style="font-size: 12px;" class="{$v['dstatus']['color']}">{$v['dstatus']['text']}</a></td>
                    <td>
                        {if $v['status']==2}
                        <a href="javascript:void(0);" onclick="delBorrow('{$v["id"]}')" class="d btn-sm">删除</a>
                        {else}
                        <a href="javascript:void(0);" onclick="backBook('{$v["id"]}')" class="t btn-sm">归还</a>
                        {/if}
                    </td>
                </tr>
                {/foreach}
            </tbody>
        </table>
    </div>
</div>
{/block}

{block name='js'}
<script>
    function backBook(id) {
        common("你确定要归还此书吗？", "{:url('User/back')}?id="+id);
    }

    function delBorrow(id) {
        common("你确定要删除此记录吗？", "{:url('User/delborrow')}?id="+id)
    }
</script>
{/block}